package com.dayang.redbook.user.relation.biz.domain.mapper;

import com.dayang.redbook.user.relation.biz.domain.dataobject.FollowingDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface FollowingDOMapper {
    int deleteByPrimaryKey(Long id);

    int insert(FollowingDO record);

    int insertSelective(FollowingDO record);

    FollowingDO selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(FollowingDO record);

    int updateByPrimaryKey(FollowingDO record);

    /**
     * 查询用户关注列表
     * @param userId 用户id
     * @return
     */
    List<FollowingDO> selectByUserId(Long userId);

    /**
     * 取消关注
     * @param userId 用户id
     * @param unfollowUserId  被取消关注的用户用id
     * @return
     */
    int deleteByUserIdAndFollowingUserId(@Param("userId") Long userId,
                                         @Param("unfollowUserId") Long unfollowUserId);

    /**
     * 查询记录总数
     *
     * @param userId 用户id
     * @return
     */
    long selectCountByUserId(Long userId);

    /**
     * 分页查询
     * @param userId 用户id
     * @param offset 分页偏移量
     * @param limit 分页条数
     * @return
     */
    List<FollowingDO> selectPageListByUserId(@Param("userId") Long userId,
                                             @Param("offset") long offset,
                                             @Param("limit") long limit);

    /**
     * 查询关注用户列表 默认查询1000条
     * @param userId 用户id
     * @return
     */
    List<FollowingDO> selectAllByUserId(Long userId);

    /**
     * 关注或则取关
     * @param followingDO
     */
    int inserOrUpdate(FollowingDO followingDO);
}